package cn.yitun.chat.yitunserverimapicore.business.notice.action;

import cn.yitun.chat.yituncommonmessage.result.ResultMessage;
import cn.yitun.chat.yitungeneral.annotation.action.ActionMapping;
import cn.yitun.chat.yitungeneral.annotation.parameter.JsonDefine;
import cn.yitun.chat.yitunnetsession.session.SocketSession;
import cn.yitun.chat.yitunservercommonlib.constant.ActionTypeConstant;
import cn.yitun.chat.yitunservercommonlib.dataentity.dto.notice.TextNoticeDto;
import cn.yitun.chat.yitunservercommonlib.dataentity.vo.notice.TextNoticeVo;
import cn.yitun.chat.yitunservercommonlib.util.R;
import cn.yitun.chat.yitunserverimapicore.business.notice.service.TextNoticeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * @author yitun
 *
 */
@Component
@ActionMapping(value = ActionTypeConstant.NOTICE_ACTION_PUSH)
public class NoticeAction {

	@Resource
	TextNoticeService textNoticeService;

	/**
	 * 获取通知列表
	 */
	@ActionMapping(value = "1.1.0003")
	public ResultMessage getTextNoticeList(SocketSession socketSession, @JsonDefine("data") TextNoticeDto query) {
		Long userId = socketSession.getKey();
		PageHelper.startPage(query.getCurrentPageNo(), query.getPageSize());
		List<TextNoticeVo> list = textNoticeService.getTextNoticeList(userId);
		return new ResultMessage(R.param("page", new PageInfo<>(list)));
	}
}
